package com.twu.biblioteca;

import java.util.Collection;
import java.util.HashMap;

public class Index {
    private final HashMap<Integer, Book> books;
    private final HashMap<Integer, Movie> movies;

    public Index()
    {
        books = new HashMap<Integer, Book>();
        movies = new HashMap<Integer, Movie>();
    }

    public void add(Book book)
    {
        int id = books.size() + 1;
        book.setItemId(id);
        books.put(id, book);
    }

    public void add(Movie movie)
    {
        int id = movies.size() + 1;
        movie.setItemId(id);
        movies.put(id, movie);
    }

    public Collection<Book> getBooks()
    {
        return books.values();
    }

    public Collection<Movie> getMovies()
    {
        return movies.values();
    }

    public Book getBook(int id)
    {
        return books.get(id);
    }

    public Movie getMovie(int id)
    {
        return movies.get(id);
    }
}
